Skip to content
This repository has been archived by the owner on Dec 27, 2019. It is now read-only.

Use ERB and SafeYAML to interpolate jekyll_get configuration #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thom4parisot
Copy link

It enables to have following statements in _config.yml:

jekyll_get:
  data: attendees
  json: https://event.api/attendees?event_id=148916&api_key=<%= ENV['API_KEY'] %>
  cache: true

API_KEY=foobar bundle exec jekyll serve will be interpolate at runtime as:

jekyll_get:
  data: attendees
  json: https://event.api/attendees?event_id=148916&api_key=foobar
  cache: true

I use SafeYAML because this is how jekyll parses its YAML files and because we are the owners of the config files, I guess it is safe enough to use ERB to interpolate Ruby code only and specifically in the jekyll_get section.

ping @DirtyF

It enables to have following statements in `_config.yml`:

```yaml
jekyll_get:
  data: attendees
  json: https://event.api/attendees?event_id=148916&api_key=<%= ENV['API_KEY'] %>
  cache: true
```

`API_KEY=foobar bundle exec jekyll serve` will be interpolate at runtime as:

```yaml
jekyll_get:
  data: attendees
  json: https://event.api/attendees?event_id=148916&api_key=foobar
  cache: true
```

I use `SafeYAML` because this is how jekyll parses its YAML files and because we are the owners of the config files, I guess it is safe enough to use ERB to interpolate Ruby code only and specifically in the `jekyll_get` section.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants